package artid.com.arttogoa.parser;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import android.text.TextUtils;

public class ArtDynamicDetail extends AppItem implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	String imgurl;
	String title;
	String detail;
	String is_auth;
	String cname;
	String realname;
	String spec;
	String age;
	String code;
	List<ImageData>list;
	@Override
	public void parse(JSONObject obj) {
		if (null == obj) {
			return;
		}
		imgurl = obj.optString("imgurl");
		title = obj.optString("title");
		detail = obj.optString("detail");
		is_auth = obj.optString("is_auth");
		cname = obj.optString("cname");
		realname = obj.optString("realname");
		spec = obj.optString("spec");
		age = obj.optString("age");
		code = obj.optString("code");
		if (TextUtils.isEmpty(imgurl)) {
			JSONArray array = obj.optJSONArray("imgdata");
			if (array!=null&array.length()>0) {
				list = new ArrayList<ArtDynamicDetail.ImageData>();
				try {
					for (int i = 0; i < array.length(); i++) {
						ImageData itemData = new ImageData();
						itemData.setImgurl(array.getJSONObject(i).optString("imgurl"));
						itemData.setImgurlone(array.getJSONObject(i).optString("imgurlone"));
						itemData.setText(array.getJSONObject(i).optString("text"));
						list.add(itemData);
					}
				} catch (Exception e) {
					// TODO: handle exception
				}
			}
			
		}
		
	}

	public List<ImageData> getList() {
		return list;
	}

	public void setList(List<ImageData> list) {
		this.list = list;
	}

	public class ImageData implements Serializable{
		String imgurl;
		String imgurlone;//微观图
		String text;
		
		public String getImgurl() {
			return imgurl;
		}
		public void setImgurl(String imgurl) {
			this.imgurl = imgurl;
		}
		public String getText() {
			return text;
		}
		public void setText(String text) {
			this.text = text;
		}
		public String getImgurlone() {
			return imgurlone;
		}
		public void setImgurlone(String imgurlone) {
			this.imgurlone = imgurlone;
		}
		@Override
		public String toString() {
			return "ImageData [imgurl=" + imgurl + ", imgurlone=" + imgurlone
					+ ", text=" + text + "]";
		}
	}
	public String getImgurl() {
		return imgurl;
	}

	public void setImgurl(String imgurl) {
		this.imgurl = imgurl;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDetail() {
		return detail;
	}

	public void setDetail(String detail) {
		this.detail = detail;
	}

	public String getIs_auth() {
		return is_auth;
	}

	public void setIs_auth(String is_auth) {
		this.is_auth = is_auth;
	}

	public String getCname() {
		return cname;
	}

	public void setCname(String cname) {
		this.cname = cname;
	}

	public String getRealname() {
		return realname;
	}

	public void setRealname(String realname) {
		this.realname = realname;
	}

	public String getSpec() {
		return spec;
	}

	public void setSpec(String spec) {
		this.spec = spec;
	}

	public String getAge() {
		return age;
	}

	public void setAge(String age) {
		this.age = age;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Override
	public String toString() {
		return "ArtDynamicDetail [imgurl=" + imgurl + ", title=" + title
				+ ", detail=" + detail + ", is_auth=" + is_auth + ", cname="
				+ cname + ", realname=" + realname + ", spec=" + spec
				+ ", age=" + age + ", code=" + code + ", list=" + list + "]";
	}
}
